package ar.uade.edu.fain.ad.server.standalone;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;

import ar.uade.edu.fain.ad.common.remote.CajaServicioRemoto;
import ar.uade.edu.fain.ad.common.remote.EmpleadoServicioRemoto;
import ar.uade.edu.fain.ad.common.remote.SalonServicioRemoto;
import ar.uade.edu.fain.ad.common.remote.SwingProcessRemoto;
import ar.uade.edu.fain.ad.server.service.factory.RemoteServiceContext;

public class Server {

	public static void main(final String[] args) {
		final RemoteServiceContext context = new RemoteServiceContext();
		try {
			context.init();
			LocateRegistry.createRegistry(1099);
			Naming.rebind("//localhost/salon", 
					context.get(SalonServicioRemoto.class));
			Naming.rebind("//localhost/caja", 
					context.get(CajaServicioRemoto.class));
			Naming.rebind("//localhost/administracion", 
					context.get(SwingProcessRemoto.class));
			Naming.rebind("//localhost/empleado",
					context.get(EmpleadoServicioRemoto.class));
			System.out.println("Servidor corriendo. Revise logs.");
		} catch (MalformedURLException e) {
			e.printStackTrace();
		} catch (RemoteException e) {
			e.printStackTrace();
		}
	}
	
}
